/**
 *====================================================
* 文件名称: ClaimSurveyServiceImpl.java
 * 修订记录：
  * No    日期				作者(操作:具体内容)
  * 1.    2015年12月09日	chenxy(创建:创建文件)
  *====================================================
  * 类描述：(说明未实现或其它不应生成javadoc的内容)
  */
package com.yuexunit.finance.project.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.common.util.BeanUtils;
import com.yuexunit.finance.project.entity.ClaimSurveyEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.persist.PersistUtil;
import com.yuexunit.util.DateUtil;

/**
 * @ClassName: ClaimSurveyServiceImpl
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author chenxy
 * @date 2015年12月09日 11:07:15
 */
@Implements(ClaimSurveyService.class)
public class ClaimSurveyServiceImpl implements ClaimSurveyService {

	@Override
	public Long createClaimSurvey(ClaimSurveyEntity entity) {
		entity.setCreateDateTime(DateUtil.now());
		PersistUtil.insert(entity);
		return entity.getClaimSurveyId();
	}

	@Override
	public void updateClaimSurvey(ClaimSurveyEntity entity) {
		ClaimSurveyEntity persist = inquireClaimSurvey(entity.getClaimSurveyId());
		BeanUtils.copyProperties(entity, persist);
		PersistUtil.update(persist);
	}

	@Override
	public void renovateClaimSurvey(ClaimSurveyEntity persist) {
		PersistUtil.update(persist);
	}

	@Override
	public ClaimSurveyEntity inquireClaimSurvey(Long claimSurveyId) {
		return PersistUtil.get(ClaimSurveyEntity.class, claimSurveyId);
	}

	@Override
	public List<ClaimSurveyEntity> inquireClaimSurveyList(Long claimId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(ClaimSurveyEntity.class);
		criteria.add(Restrictions.ge("claimId", claimId));
		return PersistUtil.get(criteria);
	}

}
